home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!sukku
- From: sukku@menudo.uh.edu (sukumar)
- Newsgroups: comp.lang.c++
- Subject: GOTO and C++.
- Date: 11 Mar 1996 23:06:47 GMT
- Organization: University of Houston
- Message-ID: <4i2bm7$bmu@masala.cc.uh.edu>
- NNTP-Posting-Host: menudo.uh.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hi,
- Are there any inherent problems with GOTO and C++. In my application,
- I using GOTO and it crashes. If I remove the goto and replace it with a flag,
- everyting works fine. This is how the code looks:
-
- f()
- {
-
- char** n = NULL;
-
- n = new char*[20];
- for(i=0; i<20; i++)
- n[i] = new char[10];
-
- ...trivial error checking
-
- if(error)
- goto CLEANUP;
-
-
- ...
- I use come RWCStrings (String class) here
- ...
-
- CLEANUP:
- for(i=0; i<20; i++)
- delete [] n[i];
-
- delete [] n;
- }
-
- The program crashes on delete [] n. If I remove the goto and replace it with
- the code at the CLEANUP, I am fine. I was testing the case where error is True.
- The debugger says there is a problem in the RWCString class.
-
- I could only conclude that goto is causing the initialization of some vars to
- screw up.
-
- I'd appreciate it if someone can throw some light on this.
-
- -Srini.
-